#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <conio.c>
#include <time.h>

typedef struct space {
    void campo();
    typedef struct tiro {
        bool tbool;
        int posx;
        int posy;
        int tempo_tiro;
        bool pbool;
        int poox;
        int pooy;
        int tempo_cagada;
    };
    int c1, c2, l1, l2, l3, l4, l5;
    void invaders();

    typedef struct sinvader {
        int invx, invy;
        bool inv;
        int cond;
    };
    tiro vetor_tiro[20];
    tiro vetor_poo[3];
    sinvader vetor_invader[40];
    int qnt_inv;
    int poo1, poo2, poo0;
    bool esquerda, direita;
    bool descer_esquerda, descer_direita;
    char matriz_invader[20][50];
    int x, y, enemy, score, cont, cont_inv;
    int tempo_mov, tempo;
    char tecla;
    void atribuicao();
    void cagando();
    void cagar();
    int teclas();
    void menu();
    void movimento();
    void movimento_descer_direita();
    void movimento_descer_esquerda();
    void jscore();
    void loop_jogo();
    void abertura();
    void foguetar();
    void imprime();
    void fase2();
};

void space::atribuicao() {
    l1 = 4;
    l2 = 6;
    l3 = 8;
    l4 = 10;
    l5 = 12;
    x = 30;
    y = 18;
    enemy = 3;
    score = 1000;
    cont = 0;
    tempo = 5000;
    tempo_mov = 3000;
    qnt_inv = 0;
    for (int i = 0; i <= 40; i++) {
        vetor_invader[i].inv = false;
        vetor_invader[i].invy = 0;
        vetor_invader[i].invx = 0;
    }
    direita = true;
    esquerda = false;
    descer_direita = true;
    descer_esquerda = false;

    for (int i = 0; i <= 20; i++) {
        vetor_tiro[i].tbool = false;
        vetor_tiro[i].tempo_tiro = 0;
    }
    for (int p = 0; p <= 3; p++) {
        vetor_poo[p].pbool = false;
        vetor_poo[p].tempo_cagada = 0;
    }
}

void space::campo() {
    textcolor(LIGHTBLUE);
    int c;
    for (c = 0; c < 50; c++) {
        gotoxy(c, 1);
        printf("%c", 178);
    }
    for (c = 2; c <= 20; c++) {
        gotoxy(49, c);
        printf("%c", 178);
    }
    for (c = 2; c < 22; c++) {
        gotoxy(1, c);
        printf("%c", 178);
    }
    for (c = 0; c <= 49; c++) {
        gotoxy(c, 21);
        printf("%c", 178);
    }
}

void space::invaders() {
    textcolor(GREEN);
    int z;
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 50; j++) {
            matriz_invader[i][j] = ' '; 
        }
    }
    for (c1 = 5; c1 <= 40; c1 = c1 + 5) {
        matriz_invader[l4][c1] = '#';
        vetor_invader[qnt_inv].invy = l4;
        vetor_invader[qnt_inv].invx = c1;
        vetor_invader[qnt_inv].inv = true;
        gotoxy(vetor_invader[qnt_inv].invx, vetor_invader[qnt_inv].invy);
        printf("#");
        qnt_inv++;
    }
    for (c2 = 5; c2 <= 40; c2 = c2 + 5) {
        matriz_invader[l3][c1] = '#';
        vetor_invader[qnt_inv].invy = l3;
        vetor_invader[qnt_inv].invx = c2;
        vetor_invader[qnt_inv].inv = true;
        gotoxy(vetor_invader[qnt_inv].invx, vetor_invader[qnt_inv].invy);
        printf("#");
        qnt_inv++;
    }
    for (c2 = 5; c2 <= 40; c2 = c2 + 5) {
        matriz_invader[l2][c1] = '#';
        vetor_invader[qnt_inv].invy = l2;
        vetor_invader[qnt_inv].invx = c2;
        vetor_invader[qnt_inv].inv = true;
        gotoxy(vetor_invader[qnt_inv].invx, vetor_invader[qnt_inv].invy);
        printf("#");
        qnt_inv++;
    }
    for (c2 = 5; c2 <= 40; c2 = c2 + 5) {
        matriz_invader[l1][c1] = '#';
        vetor_invader[qnt_inv].invy = l1;
        vetor_invader[qnt_inv].invx = c2;
        vetor_invader[qnt_inv].inv = true;
        gotoxy(vetor_invader[qnt_inv].invx, vetor_invader[qnt_inv].invy);
        printf("#");
        qnt_inv++;
    }
    qnt_inv--;
}

int space::teclas() {
    textcolor(LIGHTGRAY);
    if (kbhit()) {
        tecla = getch();
        switch (tecla) {
            case 'm':
                system("cls");
                printf(" \tPower Ranger Beta 1 Show Time. Xing_Ling - All Rights Reserved\n\n\t\t\t Agradece a Preferencia");
                _sleep(7500);
                exit(0);
            case 'a':
                if (x == 2) {
                    gotoxy(2, y);
                    printf("%c", 193);
                }
                else {
                    gotoxy(x, y);
                    printf(" ");
                    x--;
                    gotoxy(x, y);
                    printf("%c", 193);
                }
                break;
            case 'd':
                if (x == 48) {
                    gotoxy(48, y);
                    printf("%c", 193);
                } else {
                    gotoxy(x, y);
                    printf(" ");
                    x++;
                    gotoxy(x, y);
                    printf("%c", 193);
                }
                break;
            case 'w':
                for (int i = 0; i <= 10; i++) {
                    if (vetor_tiro[i].tbool == false) {
                        vetor_tiro[i].tbool = true;
                        vetor_tiro[i].posx = x;
                        vetor_tiro[i].posy = y - 2;
                        vetor_tiro[i].tempo_tiro = clock();
                        break;
                    }
                }
        }
    }
}

void space::foguetar(){
    for (int i = 0; i <= 20; i++){
       if (clock() > vetor_tiro[i].tempo_tiro){
            if (vetor_tiro[i].tbool == true){
                if (vetor_tiro[i].posy > 2){
                    gotoxy(vetor_tiro[i].posx, vetor_tiro[i].posy);
                    printf("|");
                    gotoxy(vetor_tiro[i].posx, vetor_tiro[i].posy + 1);
                    printf(" ");
                    vetor_tiro[i].posy--;
                    vetor_tiro[i].tempo_tiro = vetor_tiro[i].tempo_tiro + 75;
                    if (matriz_invader[vetor_tiro[i].posy][vetor_tiro[i].posx] == '#'){
                        matriz_invader[vetor_tiro[i].posy][vetor_tiro[i].posx] = ' ';
                        qnt_inv = qnt_inv -1 ;
                        for (int k = 0; k <= 40; k++){
                            if (vetor_invader[k].invx == vetor_tiro[i].posx){
                                if (vetor_invader[k].invy == vetor_tiro[i].posy){
                                    vetor_invader[k].inv = false;
                                }
                            }
                        }
                        gotoxy(vetor_tiro[i].posx, vetor_tiro[i].posy);
                        printf(" ");
                        gotoxy(vetor_tiro[i].posx, vetor_tiro[i].posy + 1);
                        printf(" ");
                        score = score + 100;
                        vetor_tiro[i].posy = 2;
                        
                    }
                }
                if (vetor_tiro[i].posy == 2){
                    gotoxy(vetor_tiro[i].posx, vetor_tiro[i].posy + 1);
                    printf(" ");
                    vetor_tiro[i].tbool = false;
                }
            }
        }
    }
}

void space::cagar(){
     textcolor(YELLOW);
    for (int i = 0; i <= 3; i++){
        if (clock() > vetor_poo[i].tempo_cagada){
            if (vetor_poo[i].pbool == true){
                if (vetor_poo[i].pooy < 20){
                    gotoxy(vetor_poo[i].poox, vetor_poo[i].pooy);
                    printf("|");
                    gotoxy(vetor_poo[i].poox, vetor_poo[i].pooy - 1);
                    printf(" ");
                    vetor_poo[i].pooy++;
                    vetor_poo[i].tempo_cagada = vetor_poo[i].tempo_cagada + 150;
                    if (vetor_poo[i].pooy == y) {
                        if (vetor_poo[i].poox == x) {
                            enemy--;
                            jscore();
                        }
                    }
                }
                if (vetor_poo[i].pooy == 20){
                    gotoxy(vetor_poo[i].poox, vetor_poo[i].pooy - 1);
                    printf(" ");
                    vetor_poo[i].pbool = false;
                    break;
                }
            }
        }
    }
}

void space::cagando() {
     textcolor(YELLOW);
    if (vetor_poo[0].pbool == false) {
        vetor_poo[0].pbool = true;
        poo0 = rand() % 7;
        if (vetor_invader[poo0].inv == false) {
            poo0 = poo0 + 8;
            if (vetor_invader[poo0].inv == false) {
                poo0 = poo0 + 8;
                if (vetor_invader[poo0].inv == false) {
                    poo0 = poo0 + 8;
                    if (vetor_invader[poo0].inv == false) {
                        vetor_poo[0].pbool = false;
                    }
                }
            }
        }
        vetor_poo[0].poox = vetor_invader[poo0].invx;
        vetor_poo[0].pooy = vetor_invader[poo0].invy + 2;
        vetor_poo[0].tempo_cagada = clock();
    }
    if (vetor_poo[1].pbool == false) {
        poo1 = rand() % 7;
        vetor_poo[1].pbool = true;
        if (vetor_invader[poo1].inv == false) {
            poo1 = poo1 + 8;
            if (vetor_invader[poo1].inv == false) {
                poo1 = poo1 + 8;
                if (vetor_invader[poo1].inv == false) {
                    poo1 = poo1 + 8;
                    if (vetor_invader[poo1].inv == false) {
                        vetor_poo[1].pbool = false;
                    }
                }
            }
        }
        vetor_poo[1].poox = vetor_invader[poo1].invx;
        vetor_poo[1].pooy = vetor_invader[poo1].invy + 2;
        vetor_poo[1].tempo_cagada = clock();
    }
    if (vetor_poo[2].pbool == false) {
        poo2 = rand() % 7;
        vetor_poo[2].pbool = true;
        if (vetor_invader[poo2].inv == false) {
            poo2 = poo2 + 8;
            if (vetor_invader[poo2].inv == false) {
                poo2 = poo2 + 8;
                if (vetor_invader[poo2].inv == false) {
                    poo2 = poo2 + 8;
                    if (vetor_invader[poo2].inv == false) {
                        vetor_poo[2].pbool = false;
                    }
                }
            }
        }
        vetor_poo[2].poox = vetor_invader[poo2].invx;
        vetor_poo[2].pooy = vetor_invader[poo2].invy + 2;
        vetor_poo[2].tempo_cagada = clock();
    }
}

void space::movimento() {
     textcolor(GREEN);
    if (clock() > tempo_mov) {
        for (int a = 0; a <= 40; a++) {
            if (vetor_invader[a].inv == true) {
                if (vetor_invader[a].invx == 47) {
                    if (descer_direita == true) {
                        direita = false;
                        esquerda = true;
                        movimento_descer_direita();
                    }
                }
            }
        }
        for (int a = 0; a <= 40; a++) {
            if (vetor_invader[a].inv == true) {
                if (vetor_invader[a].invx == 3) {
                    if (descer_esquerda == true) {
                        direita = true;
                        esquerda = false;
                        movimento_descer_esquerda();
                    }
                }
            }
        }
        if (esquerda == true) {
            for (int m = 0; m <= 40; m++) {
                if (vetor_invader[m].inv == true) {
                    matriz_invader[vetor_invader[m].invy][vetor_invader[m].invx] = ' ';
                    gotoxy(vetor_invader[m].invx, vetor_invader[m].invy);
                    printf(" ");
                    vetor_invader[m].invx = vetor_invader[m].invx - 1;
                    matriz_invader[vetor_invader[m].invy][vetor_invader[m].invx] = '#';
                    gotoxy(vetor_invader[m].invx, vetor_invader[m].invy);
                    printf("#");
                }
            }
        }
        if (direita == true) {
            for (int m = 0; m <= 40; m++) {
                if (vetor_invader[m].inv == true) {
                    matriz_invader[vetor_invader[m].invy][vetor_invader[m].invx] = ' ';
                    gotoxy(vetor_invader[m].invx, vetor_invader[m].invy);
                    printf(" ");
                    vetor_invader[m].invx = vetor_invader[m].invx + 1;
                    matriz_invader[vetor_invader[m].invy][vetor_invader[m].invx] = '#';
                    gotoxy(vetor_invader[m].invx, vetor_invader[m].invy);
                    printf("#");
                }
            }
        }
        tempo_mov = tempo_mov + 2000;
    }
}

void space::movimento_descer_direita() {
    descer_direita = false;
    descer_esquerda = true;
    for (int m = 0; m <= 40; m++) {
        if (vetor_invader[m].inv == true) {
            matriz_invader[vetor_invader[m].invy][vetor_invader[m].invx] = ' ';
            gotoxy(vetor_invader[m].invx, vetor_invader[m].invy);
            printf(" ");
            vetor_invader[m].invy = vetor_invader[m].invy + 1;
            matriz_invader[vetor_invader[m].invy][vetor_invader[m].invx] = '#';
            gotoxy(vetor_invader[m].invx, vetor_invader[m].invy);
            printf("#");
        }
    }
}

void space::movimento_descer_esquerda() {
    descer_esquerda = false;
    descer_direita = true;
    for (int m = 0; m <= 40; m++) {
        if (vetor_invader[m].inv == true) {
            matriz_invader[vetor_invader[m].invy][vetor_invader[m].invx] = ' ';
            gotoxy(vetor_invader[m].invx, vetor_invader[m].invy);
            printf(" ");
            vetor_invader[m].invy = vetor_invader[m].invy + 1;
            matriz_invader[vetor_invader[m].invy][vetor_invader[m].invx] = '#';
            gotoxy(vetor_invader[m].invx, vetor_invader[m].invy);
            printf("#");
        }
    }
}

void space::jscore() {
    textcolor(LIGHTBLUE);
    gotoxy(63, 2);
    printf("Score: %d", score);
    gotoxy(63, 4);
    printf("Continue: %d", enemy);
    gotoxy(63, 6);
    printf("Cont %d", cont);
    gotoxy(63, 8);
    printf("Tempo de jogo %d", clock() / 1000);
    gotoxy(63, 10);
    printf("Tempo %d", tempo);
    gotoxy(63, 12);
    printf("invasores: %d", qnt_inv);
    
}

void space:: fase2(){
     

    l1 = 4;
    l2 = 6;
    l3 = 8;
    l4 = 10;
    l5 = 12;
    x = 30;
    y = 18;
    enemy = 3;
    score = 4200;
    cont = 0;
    tempo = 5000;
    tempo_mov = 3000;
    qnt_inv = 0;
    for (int i = 0; i <= 40; i++) {
        vetor_invader[i].inv = false;
        vetor_invader[i].invy = 0;
        vetor_invader[i].invx = 0;
    }
    direita = true;
    esquerda = false;
    descer_direita = true;
    descer_esquerda = false;

    for (int i = 0; i <= 20; i++) {
        vetor_tiro[i].tbool = false;
        vetor_tiro[i].tempo_tiro = 0;
    }
    for (int p = 0; p <= 3; p++) {
        vetor_poo[p].pbool = false;
        vetor_poo[p].tempo_cagada = 0;
    }
    
    textcolor(GREEN);
    int z;
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 50; j++) {
            matriz_invader[i][j] = ' '; 
        }
    }
    for (c1 = 5; c1 <= 40; c1 = c1 + 5) {
        matriz_invader[l4][c1] = '#';
        vetor_invader[qnt_inv].invy = l4;
        vetor_invader[qnt_inv].invx = c1;
        vetor_invader[qnt_inv].inv = true;
        gotoxy(vetor_invader[qnt_inv].invx, vetor_invader[qnt_inv].invy);
        printf("#");
        qnt_inv++;
    }
    for (c2 = 5; c2 <= 40; c2 = c2 + 5) {
        matriz_invader[l3][c1] = '#';
        vetor_invader[qnt_inv].invy = l3;
        vetor_invader[qnt_inv].invx = c2;
        vetor_invader[qnt_inv].inv = true;
        gotoxy(vetor_invader[qnt_inv].invx, vetor_invader[qnt_inv].invy);
        printf("#");
        qnt_inv++;
    }
    for (c2 = 5; c2 <= 40; c2 = c2 + 5) {
        matriz_invader[l2][c1] = '#';
        vetor_invader[qnt_inv].invy = l2;
        vetor_invader[qnt_inv].invx = c2;
        vetor_invader[qnt_inv].inv = true;
        gotoxy(vetor_invader[qnt_inv].invx, vetor_invader[qnt_inv].invy);
        printf("#");
        qnt_inv++;
    }
    for (c2 = 5; c2 <= 40; c2 = c2 + 5) {
        matriz_invader[l1][c1] = '#';
        vetor_invader[qnt_inv].invy = l1;
        vetor_invader[qnt_inv].invx = c2;
        vetor_invader[qnt_inv].inv = true;
        gotoxy(vetor_invader[qnt_inv].invx, vetor_invader[qnt_inv].invy);
        printf("#");
        qnt_inv++;
    }
    qnt_inv--;

     
       textcolor(LIGHTBLUE);
    int c;
    for (c = 0; c < 50; c++) {
        gotoxy(c, 1);
        printf("%c", 178);
    }
    for (c = 2; c <= 20; c++) {
        gotoxy(49, c);
        printf("%c", 178);
    }
    for (c = 2; c < 22; c++) {
        gotoxy(1, c);
        printf("%c", 178);
    }
    for (c = 0; c <= 49; c++) {
        gotoxy(c, 21);
        printf("%c", 178);
    }

     
     
   
    textcolor(LIGHTBLUE);
    gotoxy(63, 2);
    printf("Score: %d", score);
    gotoxy(63, 4);
    printf("Continue: %d", enemy);
    gotoxy(63, 6);
    printf("Cont %d", cont);
    gotoxy(63, 8);
    printf("Tempo de jogo %d", clock() / 1000);
    gotoxy(63, 10);
    printf("Tempo %d", tempo);
    gotoxy(63, 12);
    printf("invasores: %d", qnt_inv);
     

     textcolor(YELLOW);
    if (vetor_poo[0].pbool == false) {
        vetor_poo[0].pbool = true;
        poo0 = rand() % 9;
        if (vetor_invader[poo0].inv == false) {
            poo0 = poo0 + 8;
            if (vetor_invader[poo0].inv == false) {
                poo0 = poo0 + 8;
                if (vetor_invader[poo0].inv == false) {
                    poo0 = poo0 + 8;
                    if (vetor_invader[poo0].inv == false) {
                        vetor_poo[0].pbool = false;
                    }
                }
            }
        }
        vetor_poo[0].poox = vetor_invader[poo0].invx;
        vetor_poo[0].pooy = vetor_invader[poo0].invy + 2;
        vetor_poo[0].tempo_cagada = clock();
    }
    if (vetor_poo[1].pbool == false) {
        poo1 = rand() % 7;
        vetor_poo[1].pbool = true;
        if (vetor_invader[poo1].inv == false) {
            poo1 = poo1 + 8;
            if (vetor_invader[poo1].inv == false) {
                poo1 = poo1 + 8;
                if (vetor_invader[poo1].inv == false) {
                    poo1 = poo1 + 8;
                    if (vetor_invader[poo1].inv == false) {
                        vetor_poo[1].pbool = false;
                    }
                }
            }
        }
        vetor_poo[1].poox = vetor_invader[poo1].invx;
        vetor_poo[1].pooy = vetor_invader[poo1].invy + 2;
        vetor_poo[1].tempo_cagada = clock();
    }
    if (vetor_poo[2].pbool == false) {
        poo2 = rand() % 7;
        vetor_poo[2].pbool = true;
        if (vetor_invader[poo2].inv == false) {
            poo2 = poo2 + 8;
            if (vetor_invader[poo2].inv == false) {
                poo2 = poo2 + 8;
                if (vetor_invader[poo2].inv == false) {
                    poo2 = poo2 + 8;
                    if (vetor_invader[poo2].inv == false) {
                        vetor_poo[2].pbool = false;
                    }
                }
            }
        }
        vetor_poo[2].poox = vetor_invader[poo2].invx;
        vetor_poo[2].pooy = vetor_invader[poo2].invy + 2;
        vetor_poo[2].tempo_cagada = clock();
    }  
}   
     

void space::menu() {
     

{       
        textcolor (LIGHTGRAY);
        
        
        char op;
        int i,j,k=178;
        int si[7][57]={
          //  1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57                                             
            {178,178,178,200,178,178,178,200,178,178,178,200,178,178,178,200,178,178,178,200,200,200,178,178,178,200,178,178,200,200,178,200,178,200,200,200,178,200,178,178,178,200,178,178,200,200,178,178,178,200,178,178,178,200,178,178,178},
            {178,200,200,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,200,200,200,200,200,178,200,200,178,178,200,200,178,200,178,200,200,200,178,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,178,200,178,200,200},
            {178,200,200,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,200,200,200,200,200,178,200,200,178,200,178,200,178,200,178,200,200,200,178,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,178,200,178,200,200},
            {178,178,178,200,178,178,178,200,178,178,178,200,178,200,200,200,178,178,200,200,200,200,200,178,200,200,178,200,178,200,178,200,200,178,200,178,200,200,178,178,178,200,178,200,178,200,178,178,200,200,178,178,178,200,178,178,178},
            {200,200,178,200,178,200,200,200,178,200,178,200,178,200,200,200,178,200,200,200,200,200,200,178,200,200,178,200,200,178,178,200,200,178,200,178,200,200,178,200,178,200,178,200,178,200,178,200,200,200,178,178,200,200,200,200,178},
            {200,200,178,200,178,200,200,200,178,200,178,200,178,200,200,200,178,200,200,200,200,200,200,178,200,200,178,200,200,178,178,200,200,178,200,178,200,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,178,200,200,200,178},
            {178,178,178,200,178,200,200,200,178,200,178,200,178,178,178,200,178,178,178,200,200,200,178,178,178,200,178,200,200,200,178,200,200,200,178,200,200,200,178,200,178,200,178,178,200,200,178,178,178,200,178,200,178,200,178,178,178},
            };
            
        int bixo[8][8];
      
      for(int x = 0; x < 8; x++)
              for(int y = 0; y < 8; y++)
                    bixo[x][y] = 0;
      
      bixo[0][3] = 219;
      bixo[0][4] = 219;
      
      bixo[1][2] = 219;
      bixo[1][3] = 219;
      bixo[1][4] = 219;
      bixo[1][5] = 219;
      
      bixo[2][1] = 219;
      bixo[2][2] = 219;
      bixo[2][3] = 219;
      bixo[2][4] = 219;
      bixo[2][5] = 219;
      bixo[2][6] = 219;
      
      bixo[3][0] = 219;
      bixo[3][1] = 219;
      bixo[3][3] = 219;
      bixo[3][4] = 219;
      bixo[3][6] = 219;
      bixo[3][7] = 219;
      
      for(int x = 0; x < 8; x++)
              bixo[4][x] = 219;
      
      bixo[5][1] = 219;
      bixo[5][3] = 219;
      bixo[5][4] = 219;
      bixo[5][6] = 219;
      
      bixo[6][0] = 219;
      bixo[6][7] = 219;
      
      bixo[7][1] = 219;
      bixo[7][6] = 219;
      

       do
       {
                 
        system("cls");   
        printf("\n");
       for (i=0; i<7; i++)
       {
           printf("\t  ");
            for (j=0; j<57; j++)
                {
                if(si[i][j] == 178)
                {
                printf("%c",k);
                _sleep(5);
                }
                else
                {
                printf(" ");
                _sleep(5);
                }
                }
            printf("\n");
            _sleep(60);
      }
      
      printf("\n");
      for(int x = 0; x < 8; x++){
              printf("\n\t\t\t\t");
              for(int y = 0; y < 8; y++){
                    printf("%c", bixo[x][y]);
                    printf("%c", bixo[x][y]);
                    }
      } 
      printf("\n\n\n\n\t\t\t\t[Pressione Enter]\n\n\t\t    Version Mega Plus ++ Power Ranger Beta 1\n\t\t         Show Time. All Rights Reserved");
      
      op = getch();
      
      }
      while(op!='\r');
      
      system("cls");     
     
}
     
     int bixo[8][8];
      
      for(int x = 0; x < 8; x++)
              for(int y = 0; y < 8; y++)
                    bixo[x][y] = 0;
      
      bixo[0][3] = 219;
      bixo[0][4] = 219;
      
      bixo[1][2] = 219;
      bixo[1][3] = 219;
      bixo[1][4] = 219;
      bixo[1][5] = 219;
      
      bixo[2][1] = 219;
      bixo[2][2] = 219;
      bixo[2][3] = 219;
      bixo[2][4] = 219;
      bixo[2][5] = 219;
      bixo[2][6] = 219;
      
      bixo[3][0] = 219;
      bixo[3][1] = 219;
      bixo[3][3] = 219;
      bixo[3][4] = 219;
      bixo[3][6] = 219;
      bixo[3][7] = 219;
      
      for(int x = 0; x < 8; x++)
              bixo[4][x] = 219;
      
      bixo[5][1] = 219;
      bixo[5][3] = 219;
      bixo[5][4] = 219;
      bixo[5][6] = 219;
      
      bixo[6][0] = 219;
      bixo[6][7] = 219;
      
      bixo[7][1] = 219;
      bixo[7][6] = 219;
      
      for(int x = 0; x < 8; x++){
              printf("\n\t\t\t\t");
              for(int y = 0; y < 8; y++){
                    printf("%c", bixo[x][y]);
                    printf("%c", bixo[x][y]);
                    }
      } 
     
     
    int n;
voltar:
       
    printf("\t\n\n\n\n\n");
    printf("\t\t\t    ***Escolha uma op%c%co***\n\n ", 135, 198);
    printf("\t\t\t\t   1. Jogar\n");
    printf("\t\t\t\t   2. Sair\n\n");
    scanf("%d", &n);
    printf("\n");
    system("cls");
    switch (n) {
        case 1:
            loop_jogo();
            break;
        case 2:
            exit(0);
            break;
        default:
            printf("\t\t Tente Novamente!");
            menu();
            break;
    }
}

void space::loop_jogo() {
    atribuicao();
    invaders();
    campo();
    jscore();
    textcolor(LIGHTBLUE);
    gotoxy(30, 18);
    cprintf("%c", 193);
    gotoxy(63, 23);
    printf("Sair: M");
    gotoxy(63, 16);
    printf("A <-     -> D");
    gotoxy(63, 18);
    printf("Foguetar W");
    
    while (enemy != 0) {
        if (qnt_inv ==0 ) {
                system("cls");    
                fase2();  
        };
        teclas();
        foguetar();
        jscore();
        cont++;
        cagar();
        cagando();
        movimento();
    }
   
   

         
    if (enemy==0)
    system("cls");
    textcolor(LIGHTGRAY); 
    int i,j,k=178;
        int si[7][57]={
          //  1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48                                                
            {178,178,178,178,200,178,178,178,178,200,178,200,200,200,178,200,178,178,178,200,200,200,200,178,178,178,178,200,178,200,200,178,200,178,178,178,200,178,178,178,200,200,200,178,178,178,178,178},
            {178,200,200,200,200,178,200,200,178,200,178,178,200,178,178,200,178,200,200,200,200,200,200,178,200,200,178,200,178,200,200,178,200,178,200,200,200,178,200,200,178,200,200,200,178,178,178,200},
            {178,200,200,200,200,178,200,200,178,200,178,200,178,200,178,200,178,200,200,200,200,200,200,178,200,200,178,200,178,200,200,178,200,178,200,200,200,178,200,200,178,200,200,200,178,178,178,200},
            {178,200,178,178,200,178,178,178,178,200,178,200,200,200,178,200,178,178,200,200,200,200,200,178,200,200,178,200,178,200,200,178,200,178,178,200,200,178,200,200,178,200,200,200,200,178,200,200},
            {178,200,200,178,200,178,200,200,178,200,178,200,200,200,178,200,178,200,200,200,200,200,200,178,200,200,178,200,178,200,200,178,200,178,200,200,200,178,178,178,200,200,200,200,200,178,200,200},
            {178,200,200,178,200,178,200,200,178,200,178,200,200,200,178,200,178,200,200,200,200,200,200,178,200,200,178,200,200,178,178,200,200,178,200,200,200,178,200,178,178,200,200,200,200,200,200,200},
            {178,178,178,178,200,178,200,200,178,200,178,200,200,200,178,200,178,178,178,200,200,200,200,178,178,178,178,200,200,178,178,200,200,178,178,178,200,178,200,200,178,200,200,200,200,178,200,200},
            };
       for (i=0; i<7; i++)
       {
           printf("\t");
            for (j=0; j<57; j++)
                {
                if(si[i][j] == 178)
                printf("%c",k);
                else
                printf(" ");
                }
            printf("\n");
      }
      
                   printf("\n\n");
                   _sleep(3000); 
                   system("cls");
                   menu();
}



int main() {
    space i;
    i.menu();
}
